package com.example.demo.jdk.collection;

import java.util.Objects;
import java.util.function.Consumer;

/**
 * @author: htc
 * @date: Created in 10:48 2018/11/26.
 */
public interface MyIterator<E> {

    boolean hasNext();

    E next();

    /**
     */
    default void remove() {
        throw new UnsupportedOperationException("remove");
    }

    /**
     * @param action
     */
    default void forEachRemaining(Consumer<? super E> action) {
        Objects.requireNonNull(action);
        while (hasNext()) {
            action.accept(next());
        }
    }
}
